<!DOCTYPE html>
<html style="height: 100%">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>出库单打印</title>
        <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="/web/static/src/css/full.css">
        <link rel="stylesheet" href="/web/static/lib/fontawesome/css/font-awesome.css">
        <link rel="stylesheet" href="/web/static/lib/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="/web/static/src/css/base.css">

        <script language="javascript" src="/lodop/static/lib/lodop6/LodopFuncs.js"></script>
        <script language="javascript" src="/lodop/static/src/js/mathlibrary.js"></script>

        <style type="text/css" id="style">
            body{padding: 10px; font-size: 10pt}

            @media print
            {
                .print-hide {display:none}
            }

            .td_inline {
                display:block;
                overflow:hidden;
                white-space:nowrap;
                text-overflow:ellipsis;
                width: 370pt;
            }

            .nowrap{
                white-space:nowrap;
            }
            /*.table td.noborder{*/
            /*border-top: 0px;*/
            /*}*/

            .table thead tr td{font-weight: bold; font-size: 11pt}

            h4{margin: 0px;  padding: 0px;font-size: 14pt}

            h5{
                font-size:11pt; font-family:'黑体'; font-weight: bold; margin: 0px;  padding: 0px;
            }

            div{font-size: 10pt}

            span.foot_sign{border-bottom: 1px solid #ddd}

            .table tbody tr td{border-top: 1px solid #ddd;}
            .table tbody tr:last-child td{border-top: 1px solid #fff; padding: 0px}
            .table tbody tr.memo td {padding:0px; border-top:0px}

            td{font-size:10pt}

            .font-middle{
                font-size: 12pt;
            }


            .page_head{
                padding-bottom: 20px;
            }

            .underline{text-decoration: underline;}
        </style>
    </head>

    <body>
    <object  id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
        <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>

    <!-- lodop 控制脚本 -->
    <div class="controls controls-row print-hide">
        <script>
            function CheckIsInstall() {
                try{
                    window.LODOP = getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
                    //if ((LODOP!=null)&&(typeof(LODOP.VERSION)!="undefined")) alert("本机已成功安装过Lodop控件!\n  版本号:"+LODOP.VERSION);
                    return true;
                }catch(err){
                    //alert("Error:本机打印控件未安装或需要升级!");
                }
            };
            //CheckIsInstall();

            function print_preview(){
                if (!LODOP.VERSION) return;
                LODOP.PRINT_INIT("出货单");
                LODOP.SET_PRINT_PAGESIZE(0, 2110, 1400, "2410x1400");

                var strStyle = "<style>" + document.getElementById("style").innerHTML + "</style>";
                LODOP.ADD_PRINT_TABLE(100,"10","100%",380,strStyle + document.getElementById("div-body").innerHTML);
                LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
                LODOP.ADD_PRINT_HTM(0,"10","100%",109, strStyle + document.getElementById("div-header").innerHTML);
                LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);

//                LODOP.ADD_PRINT_HTM(300,10,"90%",140, strStyle + document.getElementById("div-foot").innerHTML);
//                LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
//                LODOP.SET_PRINT_STYLEA(0,"FontSize",9)
                LODOP.ADD_PRINT_TEXT(475,690,135,20,"第#页/共&页");
                LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
                //LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
                //LODOP.ADD_PRINT_BARCODE(32,600,160,18,"EAN128C","${orderId}");
                LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);

                LODOP.PREVIEW();

            }


        </script>
    {% if is_printed %}
        <span style="color:red">已经打印过了, 如果需要再次打印, 请修改出库单的是否已打印状态</span>
    {% else %}
        <a href="javascript:if (CheckIsInstall()){print_preview()}" class="btn btn-primary">联单打印预览</a>
        注: 点击按钮打印出库联单，打印A4纸按Ctrl+P键，或者菜单上面选择文件->打印，文件->页面设置里面可以去除页眉页脚
    {% endif %}
    </div>

    <!-- 出库单据表头 -->
    <div id="div-header">
        <table border="0" cellSpacing="0" cellPadding="0" width="100%">
            <tbody>
                <tr>
                    <td align="center">
                        <h4 class="page_head">{{ picking.company_id.name}}
                        {{picking.picking_type_id.name}}
                        </h4>
                    </td>
                </tr>
                <tr>
                    <td>
                        客户:<span style="font-size: 11pt">
                        {% if order.partner_id.is_company %}
                            {{ order.partner_id.name|default('', True) }}
                        {% else %}
                            {{ order.partner_id.parent_id.name|default('', True) }}
                        {% endif %}
                    </span>
                    </td>
                    <td width="200">分拣单号: {{picking.name}}</td>
                </tr>
                <tr>
                    <td>收货地址:{{ order.partner_shipping_id.state_id.name|default('', True)}}{{ order.partner_shipping_id.city|default('', True)}}{{order.partner_shipping_id.street|default('', True)}}
                        &nbsp;,&nbsp;&nbsp;
                        收货联系人:&nbsp;
                        {% if order.partner_id.is_company %}
                            {{ order.partner_id.principal|default('', True) }}
                        {% else %}
                            {{ order.partner_id.name|default('', True) }}
                        {% endif %}
                        ,&nbsp;&nbsp;
                        联系电话:{{ order.partner_shipping_id.phone|default('', True)}}
                        {% if order.partner_id.mobile %}
                            &nbsp;,&nbsp;&nbsp;
                            手机:{{ order.partner_id.mobile|default('', True) }}
                        {% endif %}

                    </td>
                    <td>关联订单: {{picking.origin}}</td>
                </tr>
            </tbody>
        </table>
    </div>

    <!-- 出库单据表身 -->
    <div id="div-body">
        <table class="table table-striped" width="100%">
            <thead>
            <tr>
                <td width="55">序号</td>
                <td class="nowrap" style="text-align: left;">产品名称</td>
                <td class="nowrap"></td>
                <td class="nowrap"></td>
                <td class="nowrap" style="text-align: left;">数量</td>
                <td class="nowrap"></td>
                <td class="nowrap"></td>
                <td class="nowrap" style="text-align: left;">产品说明</td>

            </tr>
            </thead>
            <tbody>
            {% for line in picking.move_lines %}
            <tr>
                <td>{{loop.index}}</td>
                <td colspan="3" style="text-align: left;">
                    <span>[{{line.product_id.default_code}}]{{ line.product_id.name|default('', True) }}</span>
                </td>
                <td colspan="3" style="text-align: left;">
                    <!-- ({{ line.reserved_availability|int()}}) -->
                    {{line.product_qty|int}}
                    {% if line.product_uom %}({{ line.product_uom.name }}){% endif %}</td>
                <td style="text-align: left;">{{ line.product_id.description|default('', True) }}</td>
            </tr>
            {% endfor %}

            <tr>
                <td colspan="8" style="text-align: left;border-top: 1px solid #ddd;">
                   备注：
                </td>
            </tr>
            {% if order.note %}
                {% for line in order.note.split('\n') %}
            <tr class="memo">
                <td colspan="8">
                    {{ line }}
                </td>
            </tr>
                {% endfor %}
            {% endif %}
            </tbody>
        </table>
    </div>

    <!-- 出库单据表尾 -->
    <!--<div id="div-foot">-->
        <!--<table width="100%" border="0">-->
            <!--<tr>-->
                <!--<td>物流名称：{{ picking.carrier_id.name|default('', True)}}</td>-->
                <!--<td>货运单号：{{ picking.carrier_tracking_ref|default('', True)}}</td>-->
                <!--<td>查询电话：{{ picking.carrier_id.partner_id.phone|default('', True)}}</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td>重量：</td>-->
                <!--<td>体积：</td>-->
                <!--<td>件数：{{ picking.number_of_packages|default('0', True)}} 件</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td>实际发货日期：-->
                    <!--{%if picking.date_done%}-->
                        <!--{{ picking.date_done|strftime('%Y-%m-%d')}}-->
                    <!--{%endif%}-->
                <!--</td>-->
                <!--<td colspan="2">预计到货日期：</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td>付款方式：-->
                    <!--{% if order.freight_type == 'freight_paid' %}-->
                    <!--垫付-->
                    <!--{% elif order.freight_type == 'freight_free' %}-->
                    <!--包运费-->
                    <!--{% else %}-->
                    <!--到付-->
                    <!--{% endif %}-->
                <!--</td>-->
                <!--<td>-->
                    <!--寄付元-->
                    <!--{% if order.freight_type == 'freight_paid' %}-->
                        <!--:￥{{picking.freight|default('0.00', True)}}  元-->
                    <!--<script>-->
                        <!--document.write("  ("+cmycurd({{picking.freight}})+")");-->
                    <!--</script>-->
                    <!--{% endif %}-->
                <!--</td>-->
                <!--<td>-->
                    <!--到付元-->
                    <!--{% if order.freight_type == 'freight_collect' %}-->
                        <!--:￥{{picking.freight|default('0.00', True)}}  元-->
                    <!--<script>-->
                        <!--document.write("  ("+cmycurd({{picking.freight}})+")");-->
                    <!--</script>-->
                    <!--{% endif %}-->
                <!--</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td>送货方式：</td>-->
                <!--<td>自提 {% if order.customer_pick_up %}&nbsp;&nbsp;√ {% endif %}</td>-->
                <!--<td>送货上门 {% if order.customer_pick_up  %}{%else%}&nbsp;&nbsp;√ {% endif %}</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td>托运方签字：{{curUser.name}}</td>-->
                <!--<td colspan="2">承运方签字：</td>-->
            <!--</tr>-->
            <!--<tr>-->
                <!--<td colspan="3">收货方签字及意见：</td>-->
            <!--</tr>-->
        <!--</table>-->
    <!--</div>-->

    </body>
</html>
